// app.js
import './utils/utils.js'
import './utils/http.js'
App({
  globalData: {},
  onLaunch() {
    this.getToken()
    this.getRefreshToken()
  },
  getToken() {
    wx.getStorage({
      key: 'token',
      success: (res) => {
        this.token = res.data
      }
    })
  },
  getRefreshToken() {
    wx.getStorage({
      key: 'refreshToken',
      success: (res) => {
        this.refreshToken = res.data
      }
    })
  },
  setToken(token, refreshToken) {
    wx.setStorageSync('token', `Bearer ${token}`)
    this.token = `Bearer ${token}`

    wx.setStorageSync('refreshToken', `Bearer ${refreshToken}`)
    this.refreshToken = `Bearer ${refreshToken}`
  }
})
